package com.csy.rabbit.commit.exception;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author CSY
 */
@ControllerAdvice
public class BaseExceptionHandler {
    /**
     * 配置未知异常
     * @param e
     */
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public void error(Exception e){
        System.out.println("未知异常");
    }

    /**
     * 算数异常
     * @param e
     */
    @ExceptionHandler(value = ArithmeticException.class)
    @ResponseBody
    public void error(ArithmeticException e){
        System.out.println("算数异常");
    }

    /**v
     * 捕获id异常
     * @param e
     */
    @ExceptionHandler(value = BusinessException.class)
    @ResponseBody
    public void error(BusinessException e){
        System.out.println(e.getMessage());
    }
}
